package com.etc.service.impl;


import com.etc.dao.FavoritePersonageDao;
import com.etc.pojo.Favorite;
import com.etc.pojo.Video;
import com.etc.service.FavoritePersonageService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FavoritePersonageServiceImpl implements FavoritePersonageService {

    @Autowired
    FavoritePersonageDao favoriteDao;

    @Override
    public PageInfo<Favorite> queryAllFavoriteByUserId(String userId, Integer pageNum) {
        PageHelper.startPage(pageNum,6);
        List<Favorite> favorites = favoriteDao.queryAllFavoriteByUserId(userId);
        PageInfo<Favorite> pageInfo = new PageInfo<>(favorites);
        return pageInfo;
    }

    @Override
    public boolean deleteFavoriteByVideoId(Integer favoriteId) {
        int leep = favoriteDao.deleteFavoriteByVideoId(favoriteId);
        return leep>0;
    }
}
